<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Strict//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0"><meta http-equiv="X-UA-Compatible" content="IE=EmulateIE7" /> 
        <title>Welcome to Design Zone......</title>
        <link rel="stylesheet" type="text/css" href="../../scripts/ext/resources/css/ext-all.css" />
        <link rel="stylesheet" type="text/css" href="../../styles/dzbase.css" />
        <script type="text/javascript" src="../../scripts/ext/adapter/ext-base.js">
        </script>
        <script type="text/javascript" src="../../scripts/ext/ext-all.js">
        </script>
        <script type="text/javascript" src="../../scripts/menu/EditableItem.js">
        </script>
        <script type="text/javascript" src="../../scripts/menu/RangeMenu.js">
        </script>
        <script type="text/javascript" src="../../scripts/grid/GridFilters.js">
        </script>
        <script type="text/javascript" src="../../scripts/grid/filter/Filter.js">
        </script>
        <script type="text/javascript" src="../../scripts/grid/filter/StringFilter.js">
        </script>
        <script type="text/javascript" src="../../scripts/grid/filter/ListFilter.js">
        </script>
		<script type="text/javascript" src="../../scripts/grid/filter/DateFilter.js"></script>
		<script type="text/javascript" src="../../scripts/grid/RowExpander.js">
        </script>
        <script type="text/javascript" src="../../scripts/i18nMessage.js">
        </script>
        <script type="text/javascript" src="../../scripts/utils.js">
        </script>
        <script type="text/javascript">
        	var piMessage = new i18nMessage('../../servlet/I18nMessageServlet?keyPrefix=ui.productidentification');
			var pwfMessage = new i18nMessage('../../servlet/I18nMessageServlet?keyPrefix=ui.productworkflow');
			var referenceMessage = new i18nMessage('../../servlet/I18nMessageServlet?keyPrefix=ui.reference');
            var message = new i18nMessage('../../servlet/I18nMessageServlet?keyPrefix=message');
			
			var ctYesno = new i18nMessage('../../servlet/CodeTableServlet?name=CtYesno');
			var ctCostumeCategory = new i18nMessage('../../servlet/CodeTableServlet?name=CtCostumeCategory');
			var ctDesignType = new i18nMessage('../../servlet/CodeTableServlet?name=CtDesignType');
			var ctSeasonNumberXmlLoader = new i18nMessage('../../servlet/CodeTableServlet?name=CtSeasonNumber');
			var ctVersionXmlLoader = new i18nMessage('../../servlet/CodeTableServlet?name=CtVersion');
			var ctProductFamilyXmlLoader = new i18nMessage('../../servlet/CodeTableServlet?name=CtProductFamily');
			var ctDesignTypeXmlLoader = new i18nMessage('../../servlet/CodeTableServlet?name=CtDesignType');
			
			var store;
            var grid;
			
			var deleteCallback = function(btn){
                if (btn == 'yes') {
                    Ext.Ajax.request({
                        url: '../../servlet/ProductWorkFlowServlet?action=2&id=' + deleteId,
                        success: function(o){
                            if (o.responseText == 'success') {
                                store.reload();
                                messageTip.msg(message.get('message.tip'), message.get('message.delete.successful'));
                            }
                            else {
                                messageTip.msg(message.get('message.tip'), message.get('message.delete.unsuccessful'));
                            }
                        },
                        failure: function(o){
                            messageTip.msg(message.get('message.tip'), message.get('message.delete.failure'));
                        },
                        params: {
                            foo: 'bar'
                        }
                    });
                }
            }
			
			Ext.onReady(function(){
                Ext.QuickTips.init();
                Ext.form.Field.prototype.msgTarget = 'side';
                
                store = new Ext.data.Store({
                    // load using HTTP
                    url: '../../servlet/ProductWorkFlowServlet?action=4',
                    
                    // the return will be XML, so lets set up a reader
                    reader: new Ext.data.XmlReader({
                        record: 'item',
                        id: 'id',
                        totalRecords: 'itemTotal'
                    }, [
                     'index','id', 'piId', {
					 	name: 'productIdentification.ctProductFamily',
					 	mapping: 'ctProductFamily'
					 }, {
					 	name: 'productIdentification.ctDesignType',
					 	mapping: 'ctDesignType'
					 },{
					 	name: 'productIdentification.ctSeasonNumber',
					 	mapping: 'ctSeasonNumber'
					 },{
					 	name: 'productIdentification.ctVersion',
					 	mapping: 'ctVersion'
					 },{
					 	name: 'productIdentification.orderNumber',
					 	mapping: 'orderNumber'
					 }, {
					 	name: 'productIdentification.reference',
					 	mapping: 'reference'
					 }, {
					 	name: 'productIdentification.patronageNumer',
					 	mapping: 'patronageNumer'
					 }, 'isDesignChartFinished', 'comment1', 'isConfirmedByFactory', 'comment2','style','photoName','chartName',
					 'isConfirmedByCustomer', 'comment3', 'isPriced', 'comment4', 
					 'isConfirmedByDz', 'comment5', 'isProcurementFinished', 'comment6', 
					 'isProduceFinished', 'comment7', 'isPackageFinished', 'comment8', 
					 'isAllFinished', 'comment9']),
                    remoteSort: true
                });
			
				store.setDefaultSort('id', 'desc');
				
				var expander = new Ext.grid.RowExpander({
			        tpl : new Ext.Template(
						'<p><b>' + piMessage.get('ui.productidentification.style') + ':</b> {style}</p><br/> ',
						'<p><b>' + piMessage.get('ui.productidentification.ordernumber') + ':</b> {orderNumber} &nbsp;&nbsp;&nbsp;&nbsp;<b>' + piMessage.get('ui.productidentification.dhl') + ':</b> {dhlNumber} &nbsp;&nbsp;&nbsp;&nbsp;</p><br/>',
			            '<p><b>' + referenceMessage.get('ui.reference.front') + ':</b> {front} &nbsp;&nbsp;&nbsp;&nbsp; <b>' + referenceMessage.get('ui.reference.back') + ':</b> {back}&nbsp;&nbsp;&nbsp;&nbsp;',
						'<b>' + referenceMessage.get('ui.reference.sleeves') + ':</b> {sleeves} &nbsp;&nbsp;&nbsp;&nbsp; <b>' + referenceMessage.get('ui.reference.bottomthrum') + ':</b> {bottomThrum}&nbsp;&nbsp;&nbsp;&nbsp;',
						'<b>' + referenceMessage.get('ui.reference.sleevesthrum') + ':</b> {sleevesThrum} &nbsp;&nbsp;&nbsp;&nbsp; <b>' + referenceMessage.get('ui.reference.necklinethrum') + ':</b> {necklineThrum}&nbsp;&nbsp;&nbsp;&nbsp;</p><br/>',
			            '<p><b>' + referenceMessage.get('ui.reference.needle') + ':</b> {needle} &nbsp;&nbsp;&nbsp;&nbsp; <b>' + referenceMessage.get('ui.reference.machinetype') + ':</b> {ctMachineType}&nbsp;&nbsp;&nbsp;&nbsp;',
						'<b>' + referenceMessage.get('ui.reference.weight') + ':</b> {weight} &nbsp;&nbsp;&nbsp;&nbsp; <b>',// + piMessage.get('ui.productidentification.yarnnumber') + ':</b> {yarnNumber}&nbsp;&nbsp;&nbsp;&nbsp;',
						'</p><br/>',
						'<p><img src="../../_temp/{chartName}" width="150px"/> &nbsp;&nbsp;&nbsp;&nbsp;<img src="../../_temp/{photoName}" width="150px"/>',
						//&nbsp;&nbsp;&nbsp;&nbsp;<img src="../../_temp/{frontPhotoName}" width="150px"/>&nbsp;&nbsp;&nbsp;&nbsp;<img src="../../_temp/{backPhotoName}" width="150px"/>&nbsp;&nbsp;&nbsp;&nbsp;<img src="../../_temp/{otherPhotoName}" width="150px"/></p><br/>',
						'<br/><br/><p><b>' + piMessage.get('ui.productidentification.comment') + ':</b> {comment}</p><br/>'
			        )
			    });
				
				var filters = new Ext.grid.GridFilters({
					  filters:[
						{type: 'string',  dataIndex: 'productIdentification.orderNumber'},
						{type: 'string',  dataIndex: 'productIdentification.patronageNumer'},
						{type: 'string',  dataIndex: 'productIdentification.reference'},
						{type: 'list',  dataIndex: 'productIdentification.ctSeasonNumber', options: ctSeasonNumberXmlLoader.getCtArray() },
						{type: 'list',  dataIndex: 'productIdentification.ctProductFamily', options: ctProductFamilyXmlLoader.getCtArray() },
						{type: 'list',  dataIndex: 'productIdentification.ctDesignType', options: ctDesignTypeXmlLoader.getCtArray() },
						{type: 'list',  dataIndex: 'productIdentification.ctVersion',options: ctVersionXmlLoader.getCtArray()},
						{type: 'string',  dataIndex: 'name'},
						{type: 'date',  dataIndex: 'finishedTime'},
						{type: 'date',  dataIndex: 'alarmTime'},
						{
						      type: 'list',  
						      dataIndex: 'isEffective', 
						      options: ctYesno.getCtArray()
					    },
						{
						      type: 'list',  
						      dataIndex: 'isFinished', 
						      options: ctYesno.getCtArray()
					    }
				]});
				
				grid = new Ext.grid.GridPanel({
                    title: pwfMessage.get('ui.productworkflow.listtitle'),
                    store: store,
					stripeRows: true,
					plugins: [filters,expander],
                    height: 560,
                    columns: [expander,{
                        header: message.get('message.list.id'),
                        width: 50,
                        dataIndex: 'index',
                        sortable: false
                    },{
                        header: message.get('message.edit.productfamily'),
                        dataIndex: 'productIdentification.ctProductFamily',
						width: 60,
                        sortable: true
                    },{
                        header: piMessage.get('ui.productidentification.designtype'),
                        dataIndex: 'productIdentification.ctDesignType',
                        sortable: true
                    },{
                        header: referenceMessage.get('ui.reference.reference'),
                        dataIndex: 'productIdentification.reference',
                        sortable: true
                    },{
                        header: piMessage.get('ui.productidentification.seasonnumber'),
                        dataIndex: 'productIdentification.ctSeasonNumber',
                        sortable: true
                    },{
                        header: piMessage.get('ui.productidentification.chartversion'),
                        dataIndex: 'productIdentification.ctVersion',
                        sortable: true
                    },{
                        header: piMessage.get('ui.productidentification.patronagenumer'),
                        dataIndex: 'productIdentification.patronageNumer',
                        sortable: true
                    },{
                        header: piMessage.get('ui.productidentification.ordernumber'),
                        dataIndex: 'productIdentification.orderNumber',
                        sortable: true
                    },{
                        header: pwfMessage.get('ui.productworkflow.isdesignchartfinished'),
                        dataIndex: 'isDesignChartFinished',
                        sortable: true,
						renderer: renderIsDesignChartFinished
                    },{
                        header: pwfMessage.get('ui.productworkflow.isconfirmedbyfactory'),
                        dataIndex: 'isConfirmedByFactory',
                        sortable: true,
						renderer: renderIsConfirmedByFactory
                    },{
                        header: pwfMessage.get('ui.productworkflow.isconfirmedbycustomer'),
                        dataIndex: 'isConfirmedByCustomer',
                        sortable: true,
						renderer: renderIsConfirmedByCustomer
                    },{
                        header: pwfMessage.get('ui.productworkflow.ispriced'),
                        dataIndex: 'isPriced',
                        sortable: true,
						renderer: renderIsPriced
                    },{
                        header: pwfMessage.get('ui.productworkflow.isconfirmedbydz'),
                        dataIndex: 'isConfirmedByDz',
                        sortable: true,
						renderer: renderIsConfirmedByDz
                    },{
                        header: pwfMessage.get('ui.productworkflow.isprocurementfinished'),
                        dataIndex: 'isProcurementFinished',
                        sortable: true,
						renderer: renderIsProcurementFinished
                    },{
                        header: pwfMessage.get('ui.productworkflow.isproducefinished'),
                        dataIndex: 'isProduceFinished',
                        sortable: true,
						renderer: renderIsProduceFinished
                    },{
                        header: pwfMessage.get('ui.productworkflow.ispackagefinished'),
                        dataIndex: 'isPackageFinished',
                        sortable: true,
						renderer: renderIsPackageFinished
                    },{
                        header: pwfMessage.get('ui.productworkflow.isallfinished'),
                        dataIndex: 'isAllFinished',
                        sortable: true,
						renderer: renderIsAllFinished
                    },{
                        header: message.get('message.edit.output'),
                        width: 50,
                        dataIndex: 'id',
                        sortable: false,
                        renderer: renderReport
                    },{
                        header: message.get('message.list.eidt'),
                        width: 50,
                        dataIndex: 'piId',
                        sortable: false,
                        renderer: renderEdit
                    }],
                    viewConfig: {
                        forceFit: true
                    },
                    loadMask: true,
                    renderTo: 'productWorkFlowGrid',
                    bbar: new Ext.PagingToolbar({
                        pageSize: 20,
                        store: store,
                        displayInfo: true
                    })
                });
                
                var startPage = getPrarmeterValue(window.location, 'startPage');
                var start;
                if (startPage == null || startPage == '') {
                    start = 0;
                }
                else {
                    start = (startPage - 1) * 20;
                }
                store.load({
                    params: {
                        start: start,
                        limit: 20
                    }
                });
				
				function renderIsDesignChartFinished(value, p, record){
					if(value == '02')
						return String.format('<img ext:qtip="{0}" src="../../images/icons/cross.png" />', record.data.comment1);
					else
						return String.format('<img ext:qtip="{0}" src="../../images/icons/tick.png"/>', record.data.comment1);
                }
				
				function renderIsConfirmedByFactory(value, p, record){
					if(value == '02')
						return String.format('<img ext:qtip="{0}" src="../../images/icons/cross.png" />', record.data.comment2);
					else
						return String.format('<img ext:qtip="{0}" src="../../images/icons/tick.png"/>', record.data.comment2);
                }
				
				function renderIsConfirmedByCustomer(value, p, record){
					if(value == '02')
						return String.format('<img ext:qtip="{0}" src="../../images/icons/cross.png" />', record.data.comment3);
					else
						return String.format('<img ext:qtip="{0}" src="../../images/icons/tick.png"/>', record.data.comment3);
                }
				
				function renderIsPriced(value, p, record){
					if(value == '02')
						return String.format('<img ext:qtip="{0}" src="../../images/icons/cross.png" />', record.data.comment4);
					else
						return String.format('<img ext:qtip="{0}" src="../../images/icons/tick.png"/>', record.data.comment4);
                }
				
				function renderIsPriced(value, p, record){
					if(value == '02')
						return String.format('<img ext:qtip="{0}" src="../../images/icons/cross.png" />', record.data.comment4);
					else
						return String.format('<img ext:qtip="{0}" src="../../images/icons/tick.png"/>', record.data.comment4);
                }
				
				function renderIsConfirmedByDz(value, p, record){
					if(value == '02')
						return String.format('<img ext:qtip="{0}" src="../../images/icons/cross.png" />', record.data.comment5);
					else
						return String.format('<img ext:qtip="{0}" src="../../images/icons/tick.png"/>', record.data.comment5);
                }
				
				function renderIsProcurementFinished(value, p, record){
					if(value == '02')
						return String.format('<img ext:qtip="{0}" src="../../images/icons/cross.png" />', record.data.comment6);
					else
						return String.format('<img ext:qtip="{0}" src="../../images/icons/tick.png"/>', record.data.comment6);
                }
				
				function renderIsProduceFinished(value, p, record){
					if(value == '02')
						return String.format('<img ext:qtip="{0}" src="../../images/icons/cross.png" />', record.data.comment7);
					else
						return String.format('<img ext:qtip="{0}" src="../../images/icons/tick.png"/>', record.data.comment7);
                }
				
				function renderIsPackageFinished(value, p, record){
					if(value == '02')
						return String.format('<img ext:qtip="{0}" src="../../images/icons/cross.png" />', record.data.comment8);
					else
						return String.format('<img ext:qtip="{0}" src="../../images/icons/tick.png"/>', record.data.comment8);
                }
				
				function renderIsAllFinished(value, p, record){
					if(value == '02')
						return String.format('<img ext:qtip="{0}" src="../../images/icons/cross.png" />', record.data.comment9);
					else
						return String.format('<img ext:qtip="{0}" src="../../images/icons/tick.png"/>', record.data.comment9);
                }
				
				function renderReport(value, p, record){
					return String.format('<a href="product_identification_report.jsp?id={0}" target="_blank"><img src="../../images/icons/report.png" title="' + message.get('message.edit.output') + '" /></a>', record.data.piId);
				}
				
				function renderEdit(value, p, record){
                    return String.format('<a href="product_work_flow_edit.html?id={0}&piId={1}&startPage={2}" target="_self"><img src="../../images/icons/pencil.png" title="' + message.get('message.list.eidt') + '" /></a>', record.id, record.data.piId, Math.floor((record.data.index - 1) / 20) + 1);
                }

			});
        
        </script>
    </head>
    <body>
    		<div id="productWorkFlowGrid"></div>
    </body>
</html>
